<template>
  <page-header-wrapper>
    <a-card>
      <a-table rowKey="id" :columns="columns" :data-source="data">
        <span slot="remittanceDate" slot-scope="remittanceDate"> {{ humanizeDate(remittanceDate) }}</span>
        <span slot="amount" slot-scope="amount"> {{ moneyType(amount) }}</span>
        <span slot="approve" slot-scope="_, record">
          <approve :record="record" @update="getData"></approve>
        </span>
        <span slot="operation" slot-scope="_, record">
          <detail :record="record" @update="getData"></detail>
        </span>
      </a-table>
    </a-card>
  </page-header-wrapper>
</template>
<script>
const columns = [
  {
    title: '银行',
    dataIndex: 'bank',
    key: 'bank'
  },
  {
    title: '货币',
    dataIndex: 'currency',
    key: 'currency'
  },
  {
    title: '金额',
    dataIndex: 'amount',
    key: 'amount',
    scopedSlots: { customRender: 'amount' }
  },
  {
    title: '律师',
    dataIndex: 'lawyerName',
    key: 'lawyerName'
  },
  {
    title: '汇款日期',
    dataIndex: 'remittanceDate',
    key: 'remittanceDate',
    scopedSlots: { customRender: 'remittanceDate' }
  },
  {
    title: '审批状态',
    dataIndex: 'approve',
    key: 'approve',
    scopedSlots: { customRender: 'approve' }
  },
  {
    title: '操作',
    dataIndex: 'operation',
    key: 'operation',
    scopedSlots: { customRender: 'operation' }
  }
]
import { getMoneyarrange } from '@/api/common'
import moment from 'moment'
export default {
  name: 'Submit',
  data: () => ({
    columns,
    data: []
  }),
  components: {
    approve: () => import('./com/moneyApprove.vue'),
    detail: () => import('./com/detail.vue'),
    richTextDialog: () => import('./com/RichTextDialog.vue')
  },
  mounted() {
    this.getData()
  },
  methods: {
    humanizeDate(v) {
      if (v) {
        return moment(v * 1000).format('YYYY-MM-DD') || '--'
      } else {
        return '-'
      }
    },
    moneyType(v) {
      return `${v}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
    },
    async getData() {
      var res = await getMoneyarrange()
      this.data = res.result.data.waitlist
    }
  }
}
</script>
<style lang="css" scoped></style>
